package com.ysu.shop.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ysu.shop.pojo.Orderdetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 霍京
 * @since 2021-3-03
 */
public interface OrderdetailMapper extends BaseMapper<Orderdetail> {
    @Update("Update orderdetail set status=2 where order_no=#{orderNo} AND status=0 ")
    int payment(@Param("orderNo")String orderNo);

    @Update("Update orderdetail set status=1 where order_no=#{orderNo} AND status=0")
    int cancel(@Param("orderNo")String orderNo);

    @Update("Update orderdetail set status=3,send_time=NOW() where id=#{id} AND status=2")
    int send(@Param("id")  int id);

    @Update("Update orderdetail set status=4,receive_time=NOW() where id=#{id} AND status=3")
    int receive(@Param("id")  int id);

    IPage<Map<String, Object>> getOrderItem(IPage<Orderdetail> page, @Param("id") int id, @Param(Constants.WRAPPER) Wrapper wrapper);
}
